package com.csx.base;

import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.filter.AbstractMatcherFilter;
import ch.qos.logback.core.spi.FilterReply;
import com.yh.csx.bsf.core.util.StringUtils;
import com.yh.csx.bsf.core.util.WarnUtils;


/***
 * 为日志报警服务
 */
public class LogFilter extends AbstractMatcherFilter<ILoggingEvent> {
    @Override
    public FilterReply decide(ILoggingEvent event) {
        if(event.getLevel() == Level.ERROR) {
            WarnUtils.notify(WarnUtils.ALARM_ERROR,
                    "tidb校验程序异常",
                    StringUtils.subString3(event.getFormattedMessage(),100));
        }
        return FilterReply.NEUTRAL;
    }



}

